import Database from "./Database";

export default {
  name: "DataQuery",
  methods: {
    async queryCollection(collectionName: string) {

      let db = Database.methods.Getdb();
      if (db == undefined) {
        let promise = Database.methods.init();
        await promise;
      }
      db = Database.methods.Getdb();
      if (db == undefined) {
        console.log("DataQuery: db 未定义");
        return;
      }
      const _ = db.command;
      let promise = db.collection(collectionName).get();
      let result = await promise;
      return result.data;
    },
  },
};